<template>
  <!-- 编辑评分 -->
  <h-modal class="event-modal" v-model.lazy="show" title="编辑评分" @submit="submit">
    <a-form-model ref="form" :model="form" size="large">
      <a-row :gutter="100">
        <a-col :span="24">
          <a-form-model-item label="单位名称">
            <!-- <a-input v-model.lazy="form.title" placeholder="请输入单位名称"></a-input> -->
            <p>{{ form.depart }}</p>
          </a-form-model-item>
        </a-col>
        <!-- <a-col :span="12">
          <a-form-model-item label="时间">
            <p>{{ form.createTime }}</p>
          </a-form-model-item>
        </a-col> -->
        <a-col :span="24">
          <a-form-model-item label="响应评分">
            <a-input v-model.lazy="form.reScore" :maxLength="50" placeholder="请输入响应评分"></a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="24">
          <a-form-model-item label="回复评分">
            <a-input v-model.lazy="form.replyScore" :maxLength="50" placeholder="请输入回复评分"></a-input>
          </a-form-model-item>
        </a-col>
      </a-row>

    </a-form-model>
  </h-modal>
</template>

<script>
import moment from 'moment';
import { updateScore, getUpdateScore } from '@/api/dept';
import cloneDeep from 'lodash/cloneDeep';

export default {
  props: {
    showModal: {
      type: Boolean,
      default: false
    },
    formData: {
      type: Object,
      default: () => {}
    },
    id: {
      type: String,
      default: ''
    }
  },
  model: {
    prop: 'showModal',
    event: 'update:showModal'
  },
  watch: {
    showModal: {
      handler(val) {
        this.show = val;
        if (val) {
          this.getDetail();
        }
      },
      immediate: true
    },
    show(val) {
      this.$emit('update:showModal', val);
    }
  },
  data() {
    return {
      moment,
      show: false,
      deptArr: [],
      dept: [],
      form: {
        reScore: 10
      }
    };
  },
  created() {

  },
  methods: {
    edit(formData) {
      this.form = cloneDeep(formData);
    },
    submit() {
      const { id, reScore, replyScore } = this.form;
      updateScore({ id, reScore, replyScore }).then(res => {
        this.$message.success('编辑成功');
        this.show = false;
        this.form = {};
        this.$emit('submit', true);
      });
    },
    getDetail() {
      getUpdateScore({
        id: this.id
      }).then(res => {
        this.form = res.data;
      });
    }
  }
};
</script>

<style>

</style>
